package cn.javass.dp.iterator.example7;

import java.util.Collection;
import java.util.Iterator;

public class Client {
    public static void main(String[] args) {
        SalaryManager salaryManager = new SalaryManager();
        salaryManager.calcSalary();
        AggregationIterator it = salaryManager.createIterator();

        Collection col = it.next(2);
        System.out.println("获取第一页2条数据");
        print(col);


        Collection col2 = it.next(2);
        System.out.println("获取第2页2条数据");

        print(col2);


        Collection col3 = it.previous(2);
        System.out.println("再次获取第2页2条数据");

        print(col3);
    }

    public static void  print(Collection col) {
        Iterator it = col.iterator();
        while (it.hasNext()) {
            Object obj = it.next();
            System.out.println("obj = " + obj);
        }
    }


}
